package problem118;
//118.杨辉三角
//https://leetcode.cn/problems/pascals-triangle/description/

import java.util.ArrayList;
import java.util.List;

class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>(numRows);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        ret.add(list);
        for(int i = 1; i<numRows; i++) {
            List<Integer> preList = ret.get(i-1);
            List<Integer> curList = new ArrayList<>();
            curList.add(1);
            for(int j = 1; j<i; j++) {
                curList.add(preList.get(j) + preList.get(j-1));
            }
            curList.add(1);
            ret.add(curList);
        }
        return ret;
    }
}